//
//  MovieViewController2.m
//  UI_元旦豆瓣
//
//  Created by dllo on 16/1/3.
//  Copyright © 2016年 31付冬梅. All rights reserved.
//

#import "MovieViewController2.h"
#import "MovieView.h"
#define kWidth self.view.frame.size.width
#define kHeitht self.view.frame.size.height
#import "UIImageView+WebCache.h"
#import "MovieModel.h"
@interface MovieViewController2 ()
@property (nonatomic, retain) UIScrollView *scroll;
@property (nonatomic, retain) NSMutableArray *dataArr;
@property (nonatomic, retain) NSMutableArray *movieArr;
@property (nonatomic, retain) NSMutableArray *modelArr;
@end

@implementation MovieViewController2

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
        self.scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kWidth, kHeitht)];
        _scroll.contentSize = CGSizeMake(0, kHeitht * 10);
        [self.view addSubview:_scroll];
        //数据处理
        NSString *path = [[NSBundle mainBundle] pathForResource:@"movie" ofType:@"plist"];
    self.movieArr = [[NSMutableArray alloc] initWithContentsOfFile:path];
    self.modelArr = [NSMutableArray array];
    for (NSDictionary *dic in _movieArr) {
        MovieModel *model = [MovieModel movieModel];
        [model setValuesForKeysWithDictionary:dic];
        [_modelArr addObject:model];
    }
        //
        for (NSInteger i = 0; i <= 7; i++) {
            for (NSInteger j = 0; j <= 2; j++) {
                MovieView *view1 = [[MovieView alloc] initWithFrame:CGRectMake(20 + 120 * j, 20 + 240 * i, 100, 240)];
              
//                view1.backgroundColor = [UIColor redColor];
//                NSString *str = [NSString stringWithFormat:@"%ld", i * 3 + j];
                MovieModel *model = _modelArr[i * 3 + j];
                [view1.movieImageView sd_setImageWithURL:[NSURL URLWithString:model.image]];
                view1.titleLabel.text = model.title;
                
                [_scroll addSubview:view1];
            }
        }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
